package com.example.demo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.service.Car;
import com.example.demo.service.CarMapper;
import com.example.demo.service.CarServer;
import com.example.demo.service.Persions;

@RestController
public class HelloController1 {

  @Autowired
  private CarServer carServer;

  @Autowired
  private CarMapper carMapper;

  public List<Car> findAll() {
      return carServer.findAll();
  }

  @GetMapping("/add")
  public int add(@RequestParam(value = "id", defaultValue = "") String id,@RequestParam(value = "name", defaultValue = "") String name) {
      Car car=new Car();
      car.setId(id);
      car.setNum(name);

      return carMapper.add(car);
  }
  
  @GetMapping("/getCar")
  public List<Car> getCar(@RequestParam(value = "name", defaultValue = "World") String name) {
      return carServer.findAll();
  }

  @GetMapping("/hello1")
  public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
      User u=new User();
      u.name="张三丰wwwwwww";
      u.address="兰州市";

      Persions p=new Persions();
      return String.format("Hello11"+u.name+u.address+"cc1111 %s!"+u.say("日本是中国的")+p.say("sssssssssss"), name);
  }
}
